﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BubbleBlastSolver.Classes.BusinessLogic;

namespace BubbleBlastSolver
{
    public partial class frmMain : Form
    {
        private uint m_TotalCounts;
        private uint m_CountsLeft;

        public frmMain()
        {
            InitializeComponent();
        }

        private void btnCreatePuzzle_Click(object sender, EventArgs e)
        {
            frmBubbleSessionEntry entryForm = new frmBubbleSessionEntry();
            
            if (entryForm.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            BubbleSession startSession = new BubbleSession();
            uint imageBubbleWeight = 0;

            for (uint row = 0; row < BubbleSession.ROW_COUNT; ++row)
            {
                for (uint col = 0; col < BubbleSession.COLUMN_COUNT; ++col)
                {
                    imageBubbleWeight = entryForm.GetBubbleWeight(row, col);

                    if (imageBubbleWeight > 0)
                    { 
                        startSession.CreateBubbleIn(row, col, imageBubbleWeight);
                    }
                }
            }

            startSession.Initialize();
            startSession.Index = 1;

            Game game = new Game();
            game.Solve(startSession, entryForm.ClickCount);

            entryForm.Dispose();            
        }
    }
        
}
